package m202406.d28;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/6/28 22:34
 */
public class Q165 {
    public int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        for (int i = 0; i < v1.length || i < v2.length; i++) {
            int p1 = 0;
            int p2 = 0;
            if (i < v1.length) {
                p1 = Integer.parseInt(v1[i]);
            }
            if (i < v2.length) {
                p2 = Integer.parseInt(v2[i]);
            }
            if (p1 < p2) {
                return -1;
            } else if (p1 > p2) {
                return 1;
            }
        }
        return 0;
    }
}
